package QLThongTinBanBe;


import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.border.*;
import java.lang.String;

public class QLBanBe extends Frame implements ActionListener  
{
	
	public static BanBe sv[] = new BanBe[100000];
	  int index=0,k=0,next=0,dem=0,dem_soluong=0,loi=0;
	  int soluong[] = new int[1000];
	  GhiDoc doc = new GhiDoc();
	  GhiDoc ghi = new GhiDoc();
	  KiemTraDauVao kiem_tra = new KiemTraDauVao ();
	  
	  String sid="";
	  String smasv="";
	  String sten="";
	  String smail="";
	  String slop="";
	  String squequan="";	  
	  String s_masv="";
	  String s_ten="";
	  String s_mail="";
	  String s_lop="";
	  String s_quequan="";
	  String p2="";
	  String p1="";
	  
	  int p=1;
	  float a=0;
	  int b=0;
	  //icon4
	  Icon icon_true = new ImageIcon("icon/true.icon");
	  Icon icon_false = new ImageIcon("icon/false.icon");
	  Icon icon_ok = new ImageIcon("icon/ok.png");
	  Icon icon_add = new ImageIcon("icon/them.png");
	  Icon icon_back = new ImageIcon("icon/thoat.png");
	  Icon icon_delete = new ImageIcon("icon/xoa.png");
	  Icon icon_update = new ImageIcon("icon/sua.png");
	  
	  Icon icon_login = new ImageIcon("icon/dangnhap1.png");
	  Icon icon_logout = new ImageIcon("icon/thoat.png");
	  Icon icon_search = new ImageIcon("icon/timkiem.png");
	  Icon icon_register = new ImageIcon("icon/them.png");
	  Icon icon_tieude = new ImageIcon("icon/tieude.png");
	  Icon icon_logo = new ImageIcon("icon/logo1.jpg");
	  Icon icon_left = new ImageIcon("icon/left.jpg");
	  Icon icon_righ = new ImageIcon("icon/righ.jpg");
	  Icon icon_s2 = new ImageIcon("icon/s2.jpg");
	  Icon icon_s = new ImageIcon("icon/s.jpg");
	  Icon icon_edit = new ImageIcon("icon/capnhat.png");
	  Icon icon_goto = new ImageIcon("icon/dentrang.png");
	  Icon icon_logos2 = new ImageIcon("icon/logoban_s2.jpg");
	  Icon icon_quanly = new ImageIcon("icon/quanlybanbe.jpg");
	  Icon icon_gotopage = new ImageIcon("icon/gotopage.png");
	  

	  //-----------------------------S1------------------------------------------------------------
	  Dialog dg_dangnhap = new Dialog(this,"Dang Nhap... ",true);
	  JButton login_s1 = new JButton("",icon_login);
	  JButton back_s1 = new JButton("",icon_back);
	  TextField text_id_s1;
	  TextField text_password_s1;
	  JLabel nhan_id_s1=new JLabel("Ten Dang Nhap: ");
	  JLabel nhan_password_s1=new JLabel("Mat Khau:");
	  JLabel tieu_de_s1=new JLabel("",icon_tieude,SwingConstants.CENTER);
	  JLabel logo_s1=new JLabel("",icon_logo, SwingConstants.LEFT);
	  JLabel loi_s1=new JLabel("");
	  //----------------------------S2------------------------------------------------------------
	  JButton logout_s2 = new JButton("",icon_logout);
	  JButton add_s2 = new JButton("",icon_add);
	  JButton search_s2 = new JButton("",icon_search);
	  JButton left_s2 = new JButton("",icon_left);
	  JButton righ_s2 = new JButton("",icon_righ);
	  JButton edit_s2 = new JButton("",icon_edit);
	  JButton goto_s2 = new JButton("",icon_goto);
	  
	  TextField text_search_s2;
	  TextField text_edit_s2;
	  TextField text_goto_s2;
	  TextField text_page1_s2;
	  TextField text_page2_s2;
	  TextField text_tongsosv_s2;
	  
	  TextArea ht_id;
	  TextArea ht_masv;
	  TextArea ht_ten;
	  TextArea ht_mail;
	  TextArea ht_lop;
	  TextArea ht_quequan;
	  
	  JLabel nhan_tongsosv_s2=new JLabel("Tong ID:");
	  JLabel nhan_id_s2=new JLabel("ID"); 
	  JLabel nhan_masv_s2=new JLabel("So Dien Thoai"); 
	  JLabel nhan_ten_s2=new JLabel("Ten"); 
	  JLabel nhan_mail_s2=new JLabel("EMAIL");
	  JLabel nhan_lop_s2=new JLabel("So Thich");
	  JLabel nhan_quequan_s2=new JLabel("Que Quan"); 
	  JLabel nhan_page_s2=new JLabel("Page");
	  JLabel nhan_page2_s2=new JLabel("/");
	  JLabel nhan_edit_id_s2=new JLabel("ID");  
	  JLabel nhan_logos2=new JLabel("",icon_logos2,SwingConstants.LEFT);
	  JLabel nhan_quanly=new JLabel("",icon_quanly,SwingConstants.LEFT);
	  JLabel gotopages2 = new JLabel();
	  	 
	  JLabel nhan_s2=new JLabel("",icon_s2,SwingConstants.LEFT);      
	  JLabel nhan_add_s2=new JLabel("Them moi sinh vien"); 
	  JLabel nhan_search_s2=new JLabel("Tim kiem theo TEN cua sinh vien");
	  
	  //----------------------------S3-------------------------------------------------------------
	  Dialog d_s3 = new Dialog(this,"S3",true);
	  JButton update_s3 = new JButton("",icon_update);
	  JButton delete_s3 = new JButton("",icon_delete);
	  JButton back_s3 = new JButton("",icon_back);
	  TextField text_masv_s3;
	  TextField text_ten_s3;
	  TextField text_id_s3;
	  TextField text_lop_s3;
	  TextField text_mail_s3;
	  TextField text_quequan_s3;
	  JLabel nhan_bien_soan_thong_tin_s3=new JLabel("Editorial staff information");
	  JLabel nhan_masv_s3=new JLabel("Masv");
	  JLabel nhan_ten_s3=new JLabel("Name");
	  JLabel nhan_lop_s3=new JLabel("Lop");
	  JLabel nhan_mail_s3=new JLabel("Email");
	  JLabel nhan_quequan_s3=new JLabel("Quequan");
	  JLabel nhan_id_s3=new JLabel("ID");
	  JLabel thong_bao_s3=new JLabel("Enter complete information and then press Update");
	  //---------------------------S4---------------------------------------------------------------
	  Dialog d_s4 = new Dialog(this,"S4",true);
	  JButton back_s4 = new JButton("",icon_back);
	  JLabel nhan_xac_nhan_1_s4=new JLabel("Confirm Information");
	  JLabel nhan_xac_nhan_2_s4=new JLabel("Press the OK button to write information to memory");
	  JButton ok_s4 = new JButton("",icon_ok);
	  TextArea ht_s4;
	  
	  //------------------------S5------------------------------------------------------------------
	  Dialog d_s5 = new Dialog(this,"S5",true);
	  JButton ok_s5 = new JButton("",icon_ok);
	  JLabel thong_bao_s5=new JLabel("Update successful information");
	  //-------------------------S6--------------------------------------------------------------
	  Dialog d_s6 = new Dialog(this,"S6",true);
	  JButton back_s6 = new JButton("",icon_back);
	  JLabel nhan_xac_nhan_1_s6=new JLabel("Confirm Information");
	  JLabel nhan_xac_nhan_2_s6=new JLabel("Press the OK button to write information to memory");
	  JButton delete_s6 = new JButton("",icon_delete);
	  TextArea ht_s6;
	  
	  //-------------------------S7---------------------------------------------------------------
	  Dialog d_s7 = new Dialog(this,"S7",true);
	  JButton ok_s7 = new JButton("",icon_ok);
	  JLabel thong_bao_s7=new JLabel("Delete information successfully");
	  //-----------------------ThemBan------------------------------------------------------------------
	  Dialog d_ThemBan = new Dialog(this,"ThemBan",true);
	  JLabel thong_bao_1_ThemBan=new JLabel("Hay Dien Cac Thong Tin Ve Ban Minh");
	  JLabel thong_bao_2_ThemBan=new JLabel("An Phim Back De Thoat"); 
	  JButton register_ThemBan = new JButton("",icon_register);  
	  JButton back_ThemBan = new JButton("",icon_back);
	  TextField text_masv_ThemBan;
	  TextField text_ten_ThemBan;
	  TextField text_lop_ThemBan;
	  TextField text_mail_ThemBan;
	  TextField text_quequan_ThemBan;
	  JLabel nhan_masv_ThemBan=new JLabel("Masv");
	  JLabel nhan_ten_ThemBan=new JLabel("Name");
	  JLabel nhan_lop_ThemBan=new JLabel("Lop");
	  JLabel nhan_mail_ThemBan=new JLabel("Email");
	  JLabel nhan_quequan_ThemBan=new JLabel("Quequan");
	  //-------------------------S9------------------------------------------------------------------
	  Dialog d_s9 = new Dialog(this,"S9",true);
	  JButton ok_s9 = new JButton("",icon_ok);
	  JButton logout_s9 = new JButton("",icon_logout); 
	  JLabel thong_bao_s9=new JLabel("Registration success");
	  //-----------------------S10--------------------------------------------------------------------
	  Dialog d_s10 = new Dialog(this,"S10",true);
	  JButton back_s10 = new JButton("",icon_back);
	  JLabel nhan_xac_nhan_1_s10=new JLabel("Confirm Information");
	  JLabel nhan_xac_nhan_2_s10=new JLabel("Press the OK button to write information to memory");
	  JButton ok_s10 = new JButton("",icon_ok);
	  TextArea ht_s10;
	//------------------------------------------------------------------------------------------------
	  //------------------------------------------------------------------------------------------------
	  //-------------------------S----------------------------------------------------------------------
	  Dialog d_s = new Dialog(this,"S Error",true);
	  JButton ok_s = new JButton("",icon_ok);
	  JLabel thong_bao=new JLabel("");
	  TextArea ht_s;
	 
	  //=========================================================================================================  
	  public QLBanBe(String title) 
	  { 
	    super(title);
	    setLayout(null);
	    
	    //-----------------------------------------CAP NHAT THONG TIN-----------------------------------------
	    doc.doc_masv();
	    doc.doc_ten();
	    doc.doc_mail();
	    doc.doc_lop();
	    doc.doc_quequan();
	    index = doc.doc_index();
	    for(int i=0;i<index;i++){
	    	sv[i] = new BanBe(doc.masv[i],doc.ten[i],doc.mail[i],doc.lop[i],doc.quequan[i]);
	    	}  
	    //-----------------------------------------------------------------------------------------------------
	    
	    //===============================================S=======================================
	    d_s.setLayout(null);
	    
	    
	    thong_bao.setBorder(new LineBorder(Color.red));
	    thong_bao.setBounds(20,30,360,100);
	    d_s.add(thong_bao);
	    
	    d_s.add(ok_s);
	    ok_s.addActionListener(this);
	    ok_s.setBounds(173,150,75,25);
	    ok_s.setBorder(new LineBorder(Color.white));
	        
	    d_s.setSize(400,200);
	    d_s.setLocation(200,100);    
	    d_s.setResizable(false);
	    d_s.show(false); 
	    //===============================================END S=======================================
	    
	    //==========================================S1=========================================================
	    dg_dangnhap.setLayout(null);//trinh bay tu do  
	    d_s.setSize(200, 200);
	                
	    tieu_de_s1.setBounds(3,20,610,105);
//	    tieu_de_s1.setBounds(x, y, width, height)
	    dg_dangnhap.add(tieu_de_s1);
	    logo_s1.setBounds(10,112,220,252);
	    dg_dangnhap.add(logo_s1);
	    
	    dg_dangnhap.add(nhan_id_s1);
	    nhan_id_s1.setBounds(250,130,100,25);
	    text_id_s1=new TextField(20);    
	    text_id_s1.setText("");   
	    text_id_s1.setBounds(250,160,200,25);
	    dg_dangnhap.add(text_id_s1);
	    
	    dg_dangnhap.add(nhan_password_s1);
	    nhan_password_s1.setBounds(250,190,100,25);
	    text_password_s1=new TextField(20);
	    text_password_s1.setText("");   
	    text_password_s1.setEchoChar('*');   
	    text_password_s1.setBounds(250,220,200,25);
	    dg_dangnhap.add(text_password_s1);
	    
	    login_s1.addActionListener(this);
	    dg_dangnhap.add(login_s1);
	    login_s1.setBorder(new LineBorder(Color.white));
	    login_s1.setBounds(250,250,75,25);
	    back_s1.addActionListener(this);
	    back_s1.setBorder(new LineBorder(Color.white));
	    dg_dangnhap.add(back_s1);
	    back_s1.setBounds(375,250,75,25);
	    
	    dg_dangnhap.add(loi_s1);
	    loi_s1.setBounds(250,300,200,20);
	    
	    dg_dangnhap.setSize(500,350);// hhhhh
	    dg_dangnhap.setLocation(200,100);    
	    dg_dangnhap.setResizable(false);    
	    dg_dangnhap.show(true);
	    //===========================================================END S1========================    
	   
	    
	    //===========================================================S2=============================
	    add(nhan_logos2);
	    nhan_logos2.setBounds(50,30,180,40);
	    
	    
	    nhan_quanly.setBounds(370,40,450,110);
	    nhan_quanly.setBorder(new LineBorder(Color.white));
	    add(nhan_quanly);
	    
	    add(nhan_add_s2);
	    nhan_add_s2.setBounds(50,70,180,25);    
	    add(add_s2);
	    add_s2.addActionListener(this);
	    add_s2.setBounds(180,70,75,25);
	    add_s2.setBorder(new LineBorder(Color.white));
	    add_s2.setToolTipText("Click");
	    
	    add(logout_s2);
	    logout_s2.addActionListener(this);
	    logout_s2.setBounds(875,70,75,25);
	    logout_s2.setBorder(new LineBorder(Color.white));
	    logout_s2.setToolTipText(" Thoat khoi he thong Tat ca cac thong tin se duoc luu tru lai"); 
	    	   
	    add(nhan_search_s2);
	    nhan_search_s2.setBounds(50,90,400,25);
	    
	    text_search_s2=new TextField(20);    
	    text_search_s2.setText("");   
	    text_search_s2.setBounds(50,120,200,20);
	    add(text_search_s2);
	    search_s2.setBounds(252,120,75,25);
	    search_s2.setBorder(new LineBorder(Color.white));
	    search_s2.addActionListener(this);
	    search_s2.setToolTipText("Click");
	    add(search_s2);  
	    	  
	    left_s2.setBounds(850,690,40,25);
	    left_s2.addActionListener(this);
	    left_s2.setBorder(new LineBorder(Color.white));
	    left_s2.setToolTipText("Quay lai trang truoc");
	    add(left_s2);
	    righ_s2.setBounds(890,690,40,25);
	    righ_s2.addActionListener(this);
	    righ_s2.setBorder(new LineBorder(Color.white));
	    righ_s2.setToolTipText("Chuyen den trang tiep theo");
	    add(righ_s2);
	    
	    text_edit_s2=new TextField(10);    
	    text_edit_s2.setText("");   
	    text_edit_s2.setBounds(50,690,100,20);
	    add(text_edit_s2);
	    edit_s2.setBounds(152,690,75,25);
	    edit_s2.addActionListener(this);
	    edit_s2.setBorder(new LineBorder(Color.white));
	    edit_s2.setToolTipText("Nhap ID can thay doi thong tin");
	    add(edit_s2);
	    add(nhan_edit_id_s2);
	    nhan_edit_id_s2.setBounds(50,710,20,20);
	    
	    text_goto_s2=new TextField(10);    
	    text_goto_s2.setText("");   
	    text_goto_s2.setBounds(870,130,50,20);
	    add(text_goto_s2);
	    goto_s2.setBounds(920,125,75,25);
	    goto_s2.addActionListener(this);
	    goto_s2.setBorder(new LineBorder(Color.white));
	    goto_s2.setToolTipText("Chuyen toi trang theo yeu cau");
	    add(goto_s2);
	    ////------------------------------
//	    gotopages2.setLabelFor(text_goto_s2);
//	    gotopages2.setIcon(icon_gotopage);
//	    add(gotopages2);
	    //---------------------------------
	    
	    add(nhan_id_s2);
	    nhan_id_s2.setBounds(50,160,80,20);
	    
	    add(nhan_masv_s2);
	    nhan_masv_s2.setBounds(150,160,290,20);
	    
	    
	    add(nhan_ten_s2);
	    nhan_ten_s2.setBounds(300,160,290,20);
	    
	    add(nhan_mail_s2);
	    nhan_mail_s2.setBounds(530,160,290,20);
	    
	    add(nhan_lop_s2);
	    nhan_lop_s2.setBounds(680,160,255,20);
	    
	    add(nhan_quequan_s2);
	    nhan_quequan_s2.setBounds(850,160,255,20);
	    
	    add(nhan_page_s2);
	    nhan_page_s2.setBounds(900,690,30,30);
	    add(nhan_page2_s2);
	    nhan_page2_s2.setBounds(950,690,6,30);
	    
	    text_page1_s2=new TextField(5);
	    text_page1_s2.setEditable(false);    
	    text_page1_s2.setText("1");   
	    text_page1_s2.setBounds(750,690,40,20);
	    add(text_page1_s2);
	    
	    text_page2_s2=new TextField(5);
	    text_page2_s2.setEditable(false);    
	    text_page2_s2.setText("");   
	    text_page2_s2.setBounds(800,690,40,20);
	    add(text_page2_s2);
	    
	    
	    text_tongsosv_s2=new TextField(5);
	    text_tongsosv_s2.setEditable(false);
	    String sonv=String.valueOf(index);    
	    text_tongsosv_s2.setText(sonv);   
	    text_tongsosv_s2.setBounds(550,690,40,20);
	    add(text_tongsosv_s2);
	    add(nhan_tongsosv_s2);
	    nhan_tongsosv_s2.setBounds(500,690,50,30);
	    
	    
	    ht_lop = new TextArea();
	    ht_lop.setEditable(false);
	    ht_lop.setText("");   
	    ht_lop.setBounds(650,180,150,500);
	    add(ht_lop);
	    ht_mail = new TextArea();
	    ht_mail.setEditable(false);
	    ht_mail.setText("");   
	    ht_mail.setBounds(450,180,320,500);
	    add(ht_mail);
	    ht_ten = new TextArea();
	    ht_ten.setEditable(false);
	    ht_ten.setText("");   
	    ht_ten.setBounds(260,180,250,500);
	    add(ht_ten);
	    ht_id = new TextArea();
	    ht_id.setEditable(false);
	    ht_id.setText("");   
	    ht_id.setBounds(50,180,60,500);
	    add(ht_id);
	    ht_masv = new TextArea();
	    ht_masv.setEditable(false);
	    ht_masv.setText("");   
	    ht_masv.setBounds(110,180,200,500);
	    add(ht_masv);
	    ht_quequan = new TextArea();
	    ht_quequan.setEditable(false);
	    ht_quequan.setText("");   
	    ht_quequan.setBounds(800,180,300,500);
	    add(ht_quequan);
	    
	    
	    
	    for(int i=0;i<15;i++){
					if(k==index)break;
					     String s=String.valueOf(k+1);
					     sid = sid+s+"\n--------------\n";
					     smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
					     sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
					     smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
					     slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";   
					     squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";   		
					     k++;
				}
		
		a=(float)index/15;
		b=index/15;
		if(a>b)
		   b=b+1;
		text_page2_s2.setText(p2.valueOf(b));
		ht_id.setText(sid);
		ht_masv.setText(smasv);
	    ht_ten.setText(sten);
		ht_mail.setText(smail);
		ht_lop.setText(slop);
		ht_quequan.setText(squequan);
	    
	    this.setSize(1000,740); 
	    this.show(true); 
	    //==============================================================END S2========================
	    
	    
	    
	    //===============================================S3============================================
	    d_s3.setLayout(null);
	    
	    d_s3.add(thong_bao_s3);
	    thong_bao_s3.setBounds(5,30,300,20);
	    
	    d_s3.add(nhan_id_s3);
	    nhan_id_s3.setBounds(20,50,50,25);
	    text_id_s3=new TextField(20);    
	    text_id_s3.setText("");   
	    text_id_s3.setBounds(70,50,200,20);
	    d_s3.add(text_id_s3);   
	    	
	    d_s3.add(nhan_masv_s3);
	    nhan_masv_s3.setBounds(20,100,50,25);
	    text_masv_s3=new TextField(20);    
	    text_masv_s3.setText("");   
	    text_masv_s3.setBounds(70,100,200,20);
	    d_s3.add(text_masv_s3);
	        
	    d_s3.add(nhan_ten_s3);
	    nhan_ten_s3.setBounds(20,150,50,25);
	    text_ten_s3=new TextField(20);    
	    text_ten_s3.setText("");   
	    text_ten_s3.setBounds(70,150,200,20);
	    d_s3.add(text_ten_s3);
	    
	    d_s3.add(nhan_mail_s3);
	    nhan_mail_s3.setBounds(20,200,50,25);
	    text_mail_s3=new TextField(20);    
	    text_mail_s3.setText("");   
	    text_mail_s3.setBounds(70,200,200,20);
	    d_s3.add(text_mail_s3);       
	   
	    d_s3.add(nhan_lop_s3);
	    nhan_lop_s3.setBounds(20,250,50,25);
	    text_lop_s3=new TextField(20);    
	    text_lop_s3.setText("");   
	    text_lop_s3.setBounds(70,250,200,20);
	    d_s3.add(text_lop_s3);
	    
	    d_s3.add(nhan_quequan_s3);
	    nhan_quequan_s3.setBounds(20,300,50,25);
	    text_quequan_s3=new TextField(20);    
	    text_quequan_s3.setText("");   
	    text_quequan_s3.setBounds(70,300,200,20);
	    d_s3.add(text_quequan_s3);
	    
	    d_s3.add(update_s3);
	    update_s3.addActionListener(this);
	    update_s3.setBounds(50,350,75,25);
	    update_s3.setBorder(new LineBorder(Color.white));
	    d_s3.add(delete_s3);
	    delete_s3.addActionListener(this);
	    delete_s3.setBounds(150,350,75,25);
	    delete_s3.setBorder(new LineBorder(Color.white));
	    d_s3.add(back_s3);
	    back_s3.addActionListener(this);
	    back_s3.setBounds(250,350,75,25);
	    back_s3.setBorder(new LineBorder(Color.white));

	    d_s3.setSize(400,500); 
	    d_s3.setLocation(400,300);   
	    d_s3.setResizable(false);
	    d_s3.show(false);    
	    //===============================================================END S3=========================
	    
	    
	    //=======================================S4===============================================
	    d_s4.setLayout(null);
	    
	    d_s4.add(nhan_xac_nhan_1_s4);
	    nhan_xac_nhan_1_s4.setBounds(10,30,300,25);
	    d_s4.add(nhan_xac_nhan_2_s4);
	    nhan_xac_nhan_2_s4.setBounds(10,50,300,25);
	    
	    ht_s4=new TextArea();
	    ht_s4.setEditable(false);    
	    ht_s4.setText("");   
	    ht_s4.setBounds(10,80,390,170);
	    d_s4.add(ht_s4);
	    
	    d_s4.add(ok_s4);
	    ok_s4.addActionListener(this);
	    ok_s4.setBounds(70,250,75,25);
	    ok_s4.setBorder(new LineBorder(Color.white));
	    
	    d_s4.add(back_s4);
	    back_s4.addActionListener(this);
	    back_s4.setBounds(230,250,75,25);
	    back_s4.setBorder(new LineBorder(Color.white));
	        
	    d_s4.setSize(400,290);
	    d_s4.setLocation(200,100);    
	    d_s4.setResizable(false);
	    d_s4.show(false); 
	    //==================================================END S4=======================
	    
	   
	    //===============================================S5=======================================
	    d_s5.setLayout(null);
	    
	    d_s5.add(thong_bao_s5);
	    thong_bao_s5.setBounds(60,100,180,25);
	    
	    d_s5.add(ok_s5);
	    ok_s5.addActionListener(this);
	    ok_s5.setBounds(100,160,75,25);
	    ok_s5.setBorder(new LineBorder(Color.white));
	    
	    d_s5.setSize(300,200);
	    d_s5.setLocation(200,100);    
	    d_s5.setResizable(false);
	    d_s5.show(false); 
	    //================================================END S5=====================================
	    
	   
	    //==================================================S6========================================== 
	    d_s6.setLayout(null);
	    
	    d_s6.add(nhan_xac_nhan_1_s6);
	    nhan_xac_nhan_1_s6.setBounds(10,30,300,25);
	    d_s6.add(nhan_xac_nhan_2_s6);
	    nhan_xac_nhan_2_s6.setBounds(10,50,300,25);
	    
	    ht_s6=new TextArea();
	    ht_s6.setEditable(false);    
	    ht_s6.setText("");   
	    ht_s6.setBounds(10,80,390,170);
	    d_s6.add(ht_s6);
	    
	    d_s6.add(delete_s6);
	    delete_s6.addActionListener(this);
	    delete_s6.setBounds(70,250,75,25);
	    delete_s6.setBorder(new LineBorder(Color.white));
	    
	    d_s6.add(back_s6);
	    back_s6.addActionListener(this);
	    back_s6.setBounds(230,250,75,25);
	    back_s6.setBorder(new LineBorder(Color.white));
	    
	    d_s6.setSize(400,290);
	    d_s6.setLocation(200,100);    
	    d_s6.setResizable(false);
	    d_s6.show(false); 
	    //==================================================END S6========================================== 
	    
	    
	    //===============================================S7=======================================
	    d_s7.setLayout(null);
	    
	    d_s7.add(thong_bao_s7);
	    thong_bao_s7.setBounds(60,100,180,25);
	    
	    d_s7.add(ok_s7);
	    ok_s7.addActionListener(this);
	    ok_s7.setBounds(100,160,75,25);
	    ok_s7.setBorder(new LineBorder(Color.white));
	    
	    d_s7.setSize(300,200);
	    d_s7.setLocation(200,100);    
	    d_s7.setResizable(false);
	    d_s7.show(false); 
	    //================================================END S7=====================================
	   
	   
	   
	    //========================================================ThemBan====================================
	    d_ThemBan.setLayout(null);
	    
	    d_ThemBan.add(thong_bao_1_ThemBan);
	    thong_bao_1_ThemBan.setBounds(20,30,300,25);
	    d_ThemBan.add(thong_bao_2_ThemBan);
	    thong_bao_2_ThemBan.setBounds(20,60,200,25);
	    
	    d_ThemBan.add(nhan_masv_ThemBan);
	    nhan_masv_ThemBan.setBounds(20,100,50,25);
	    text_masv_ThemBan=new TextField(20);    
	    text_masv_ThemBan.setText("");   
	    text_masv_ThemBan.setBounds(70,100,200,20);
	    d_ThemBan.add(text_masv_ThemBan);
	        
	    d_ThemBan.add(nhan_ten_ThemBan);
	    nhan_ten_ThemBan.setBounds(20,150,50,25);
	    text_ten_ThemBan=new TextField(20);    
	    text_ten_ThemBan.setText("");   
	    text_ten_ThemBan.setBounds(70,150,200,20);
	    d_ThemBan.add(text_ten_ThemBan);
	    
	    d_ThemBan.add(nhan_mail_ThemBan);
	    nhan_mail_ThemBan.setBounds(20,200,50,25);
	    text_mail_ThemBan=new TextField(20);    
	    text_mail_ThemBan.setText("");   
	    text_mail_ThemBan.setBounds(70,200,200,20);
	    d_ThemBan.add(text_mail_ThemBan);       
	   
	    d_ThemBan.add(nhan_lop_ThemBan);
	    nhan_lop_ThemBan.setBounds(20,250,50,25);
	    text_lop_ThemBan=new TextField(20);    
	    text_lop_ThemBan.setText("");   
	    text_lop_ThemBan.setBounds(70,250,200,20);
	    d_ThemBan.add(text_lop_ThemBan);
	    
	    d_ThemBan.add(nhan_quequan_ThemBan);
	    nhan_quequan_ThemBan.setBounds(20,300,50,25);
	    text_quequan_ThemBan=new TextField(20);    
	    text_quequan_ThemBan.setText("");   
	    text_quequan_ThemBan.setBounds(70,300,200,20);
	    d_ThemBan.add(text_quequan_ThemBan);
	    
	    d_ThemBan.add(register_ThemBan);
	    register_ThemBan.addActionListener(this);
	    register_ThemBan.setBounds(80,350,75,25);
	    register_ThemBan.setBorder(new LineBorder(Color.white));
	    d_ThemBan.add(back_ThemBan);
	    back_ThemBan.addActionListener(this);
	    back_ThemBan.setBounds(200,350,75,25);
	    back_ThemBan.setBorder(new LineBorder(Color.white));     
	    
	    d_ThemBan.setSize(400,500);
	    d_ThemBan.setLocation(200,100);    
	    d_ThemBan.setResizable(false);
	    d_ThemBan.show(false);  
	    //=========================================================END ThemBan=========================
	    
	    
	    
	    //===============================================S9=======================================
	    d_s9.setLayout(null);
	    
	    d_s9.add(thong_bao_s9);
	    thong_bao_s9.setBounds(60,100,180,25);
	    
	    d_s9.add(ok_s9);
	    ok_s9.addActionListener(this);
	    ok_s9.setBounds(100,160,75,25);
	    ok_s9.setBorder(new LineBorder(Color.white));
	  
	    d_s9.setSize(300,200);
	    d_s9.setLocation(200,100);    
	    d_s9.setResizable(false);
	    d_s9.show(false); 
	    //================================================END S9=====================================
	    
	    
	    //===========================================S10=========================================
	    d_s10.setLayout(null);
	    
	    d_s10.add(nhan_xac_nhan_1_s10);
	    nhan_xac_nhan_1_s10.setBounds(10,30,300,25);
	    d_s10.add(nhan_xac_nhan_2_s10);
	    nhan_xac_nhan_2_s10.setBounds(10,50,300,25);
	    
	    ht_s10=new TextArea();
	    ht_s10.setEditable(false);    
	    ht_s10.setText("");   
	    ht_s10.setBounds(10,80,390,150);
	    d_s10.add(ht_s10);
	    
	    d_s10.add(ok_s10);
	    ok_s10.addActionListener(this);
	    ok_s10.setBounds(70,230,75,25);
	    ok_s10.setBorder(new LineBorder(Color.white));
	    
	    d_s10.add(back_s10);
	    back_s10.addActionListener(this);
	    back_s10.setBounds(230,230,75,25);
	    back_s10.setBorder(new LineBorder(Color.white));
	    
	    d_s10.setSize(400,270);
	    d_s10.setLocation(200,100);    
	    d_s10.setResizable(false);
	    d_s10.show(false); 
	    
	    //===========================================END S10=====================================            
	  }    
	 //===================================================LOP SU LY CAC SU KIEN=====================================
	 public void actionPerformed(ActionEvent e)
	  { 
	    //------------------------------------------------SU LY SU KIEN S1-----------------------------------------
	    if(e.getSource()==login_s1){
	    	String user = doc.doc_user();
	    	String password = doc.doc_password(); 
	    	String s="";	  		
	    	if(kiem_tra.chuoi((text_id_s1.getText()),user)==true&&kiem_tra.chuoi((text_password_s1.getText()),password)==true)
	    		 dg_dangnhap.show(false);    		
		    else 
		    	{
		    	loi_s1.setBorder(new LineBorder(Color.blue));
		    	loi_s1.setText(" Loi Username hoac Password");
		    	}   		  
	    }
	      
	    //--------------------------------------------SU LY SU KIEN S2--------------------------------  
	    if(e.getSource()==edit_s2)
	      {
	      	int in_edit=Integer.parseInt(text_edit_s2.getText());
	      	if(in_edit-1<index&&in_edit>0){
	      		String s=String.valueOf(in_edit);
	      		text_id_s3.setText(s);
	      		text_masv_s3.setText(sv[in_edit-1].masv());
	      		text_ten_s3.setText(sv[in_edit-1].ten());
	      		text_mail_s3.setText(sv[in_edit-1].mail());
	      		text_lop_s3.setText(sv[in_edit-1].lop()); 
	      		text_quequan_s3.setText(sv[in_edit-1].quequan());     		
	      		d_s3.show(true);
	      		}
	      	else{
	      		thong_bao.setText(" Khong ton tai ID nay Moi ban nhap lai");
	      		text_edit_s2.setText("");
	      		d_s.show(true);      		
	      		}
	      	      
	      }
	    //Tim kiem theo ten-----------------SEARCH----------------------
	    if(e.getSource()==search_s2)
	      {
	      	//neu chuoi tim kiem la rong
	      	if(text_search_s2.getText().length()==0){
	      		
	      			thong_bao.setText(" Hien thi tat ca cac thong tin cua tat ca cac sinh vien");
	      			d_s.show(true);
	      			
	      		    next=0;
			      	sid="";
			      	smasv="";
			      	sten="";
			      	smail="";
			      	slop="";
			      	squequan="";
			      	k=next;
			      	for(int i=0;i<15;i++){
			      		if(k==index)break;
			      		String s=String.valueOf(k+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";		      		
			      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";
			      		k++;
			      		}
			      	ht_id.setText(sid);
			      	ht_masv.setText(smasv);
			      	ht_ten.setText(sten);
			      	ht_mail.setText(smail);
			      	ht_lop.setText(slop);
			      	ht_quequan.setText(squequan);
			      	p=1;
			      	a=(float)index/15;
					b=index/15;
					if(a>b)
					   b=b+1;
					text_page2_s2.setText(p2.valueOf(b));
			      	text_page1_s2.setText("1");
			      	
	      		}
	      	//chuoi tim kiem co gia tri
	      	else{      		
	      		sid="";
	      		smasv="";
			    sten="";
			    smail="";
			    slop="";
			    squequan="";
			    next=0;
			    dem_soluong=0;
			    for(int i=0;i<index;i++)
	      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true)
	      			{
	      				soluong[dem_soluong]=i;
	      				dem_soluong++;
	      			}
	      		
	      		if(dem_soluong==0){
		      		thong_bao.setText(" Khong tim thay ten sinh vien nay");
		      		text_search_s2.setText("");
		      		d_s.show(true);
	      		}
	      		else{
		      		a=(float)dem_soluong/15;
		      		b=dem_soluong/15;
		      		if(a>b)b=b+1;
				    dem=0;
		      		for(int i=0;i<index;i++){
		      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true){
		      				dem++;
		      				if(dem>15)break;
		      				String s2=String.valueOf(i+1);
				      		sid = sid+s2+"\n--------------\n";
				      		smasv = smasv+sv[i].masv()+"\n--------------------------------------------------------------------------\n";
				      		sten = sten+sv[i].ten()+"\n--------------------------------------------------------------------------\n";
				      		smail = smail+sv[i].mail()+"\n--------------------------------------------------------------------------\n";
				      		slop = slop+sv[i].lop()+"\n------------------------------------------------------\n";
				      		squequan = squequan+sv[i].quequan()+"\n--------------------------------------------------------------------------\n";
		      				}
		      				
		      			}
		      		ht_id.setText(sid);
		      		ht_masv.setText(smasv);
				    ht_ten.setText(sten);
				    ht_mail.setText(smail);
				    ht_lop.setText(slop);
				    ht_quequan.setText(squequan);
				    p=1;
				    text_page2_s2.setText(p2.valueOf(b));
		      		text_page1_s2.setText("1"); 
		      		}
	      		     			
	      		}
	     
	      		
	      }
	    //chuyen toi trang toi--------------------------RIGH----------------------
	    if(e.getSource()==righ_s2){		   
			   
			   if(dem_soluong>14){
			   	 next=next + 15;
			        	if(next<=dem_soluong){
					      	sid="";
					      	smasv="";
					      	sten="";
					      	smail="";
					      	slop="";
					      	squequan="";
					      	k=next;
					      	for(int i=0;i<15;i++){
					      		if(k==dem_soluong)break;
					      		String s=String.valueOf(soluong[k]);
					      		sid = sid+s+"\n--------------\n";
					      		smasv = smasv+sv[soluong[k]].masv()+"\n--------------------------------------------------------------------------\n";
					      		sten = sten+sv[soluong[k]].ten()+"\n--------------------------------------------------------------------------\n";
					      		smail = smail+sv[soluong[k]].mail()+"\n--------------------------------------------------------------------------\n";
					      		slop = slop+sv[soluong[k]].lop()+"\n------------------------------------------------------\n";   
					      		squequan = squequan+sv[soluong[k]].quequan()+"\n--------------------------------------------------------------------------\n";   		
					      		k++;
					      		}
					      	ht_id.setText(sid);
					      	ht_masv.setText(smasv);
					      	ht_ten.setText(sten);
					      	ht_mail.setText(smail);
					      	ht_lop.setText(slop);
					      	ht_quequan.setText(squequan);
					      	p=p+1;
					      	if(p>=b)
					      		p=b;
	      		            text_page1_s2.setText(p1.valueOf(p));  
			        	}
			        	else next=dem_soluong; 
			   }
			   
			   if(text_search_s2.getText().length()==0){     	
			        	next=next + 15;
			        	if(next<=index){
					      	sid="";
					      	smasv="";
					      	sten="";
					      	smail="";
					      	slop="";
					      	squequan="";
					      	k=next;
					      	for(int i=0;i<15;i++){
					      		if(k==index)break;
					      		String s=String.valueOf(k+1);
					      		sid = sid+s+"\n--------------\n";
					      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
					      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
					      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
					      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";  
					      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";    		
					      		k++;
					      		}
					      	ht_id.setText(sid);
					      	ht_masv.setText(smasv);
					      	ht_ten.setText(sten);
					      	ht_mail.setText(smail);
					      	ht_lop.setText(slop);
					      	ht_quequan.setText(squequan);
					      	
					      	p=p+1;				      	
					      	if(p>=b)
					      	   p=b;
	      		            text_page1_s2.setText(p1.valueOf(p)); 
			        	}
			        	else next=index; 
			   }
			  	
	    	}
	    
	    //quay lai trang vua qua-----------------------------LEFT----------------------------------		
	    if(e.getSource()==left_s2){		    
			    
			    if(dem_soluong>14){
			   	    next=next - 15;
			    	if(next<0)next=0;
			      	sid="";
			      	smasv="";
			      	sten="";
			      	smail="";
			      	slop="";
			      	squequan="";
			      	k=next;
			      	for(int i=0;i<15;i++){
			      		if(k==dem_soluong+1)break;
			      		String s=String.valueOf(soluong[k]+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[soluong[k]].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[soluong[k]].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[soluong[k]].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[soluong[k]].lop()+"\n------------------------------------------------------\n";	
			      		squequan = squequan+sv[soluong[k]].quequan()+"\n--------------------------------------------------------------------------\n";	      		
			      		k++;
			      		}
			      	ht_id.setText(sid);
			      	ht_masv.setText(smasv);
			      	ht_ten.setText(sten);
			      	ht_mail.setText(smail);
			      	ht_lop.setText(slop);
			      	ht_quequan.setText(squequan);
			      	p=p-1;
					if(p<=1)
					   p=1;
	      		    text_page1_s2.setText(p1.valueOf(p));
			    }	    
			    		    	    
			    if(text_search_s2.getText().length()==0){
			    	next=next - 15;
			    	if(next<0)next=0;
			      	sid="";
			      	smasv="";
			      	sten="";
			      	smail="";
			      	slop="";
			      	squequan="";
			      	k=next;
			      	for(int i=0;i<15;i++){
			      		if(k==index)break;
			      		String s=String.valueOf(k+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";
			      		k++;
			      		}
			      	ht_id.setText(sid);
			      	ht_masv.setText(smasv);
			      	ht_ten.setText(sten);
			      	ht_mail.setText(smail);
			      	ht_lop.setText(slop);
			      	ht_quequan.setText(squequan);
			      	p=p-1;				      	
					if(p<=1)
					   p=1;
	      		    text_page1_s2.setText(p1.valueOf(p)); 
			      	
			    }
	    	}
	     //su ly su kien them nhan vien--------------------------------ADD-------------------
	     if(e.getSource()==add_s2){
	    	d_ThemBan.show(true);
	    	}
	    //chuyen nhanh toi trang yeu cau---------------------GOTO--------------------
	    if(e.getSource()==goto_s2){
	    	
	    	if(text_goto_s2.getText().length()==0){
	    		thong_bao.setText(" Moi nhap so trang can chuyen toi");
	      		d_s.show(true);
	    		}
	    	if(text_goto_s2.getText().length()!=0){
	    		if(text_search_s2.getText().length()==0){
	    			//ta co b la so trang
	    			int trang=Integer.parseInt(text_goto_s2.getText());
	    			if(trang>b){
	    				String s1=String.valueOf(b);
	    				thong_bao.setText(" Trang nay khong ton tai");
	      				d_s.show(true);
	    				}
	    			else{
	    				sid="";
	    				smasv="";
				      	sten="";
				      	smail="";
				      	slop="";
				      	squequan="";
	    				next=(trang-1)*15;
	    				k=next;
	    				for(int i=0;i<15;i++){
				      		if(k==index)break;
				      		String s=String.valueOf(k+1);
				      		sid = sid+s+"\n--------------\n";
				      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
				      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
				      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
				      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";
				      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";		      		
				      		k++;
				      		}
					      	ht_id.setText(sid);
					      	ht_masv.setText(smasv);
					      	ht_ten.setText(sten);
					      	ht_mail.setText(smail);
					      	ht_lop.setText(slop);
					      	ht_quequan.setText(squequan);
					      	p=trang;
					      	text_page1_s2.setText(p1.valueOf(p));
					      	
	    				}
	    			}
	    		if(dem_soluong>14){
	    			//ta co b la so trang
	    			int trang=Integer.parseInt(text_goto_s2.getText());
	    			if(trang>b){
	    				String s1=String.valueOf(b);
	    				thong_bao.setText(" Trang nay khong ton tai");
	      				d_s.show(true);
	    				}
	    			else{
	    				sid="";
	    				smasv="";
				      	sten="";
				      	smail="";
				      	slop="";
				      	squequan="";
	    				next=(trang-1)*15;
	    				k=next;
	    				for(int i=0;i<15;i++){
				      		if(k==dem_soluong+1)break;
				      		String s=String.valueOf(soluong[k]);
				      		sid = sid+s+"\n--------------\n";
				      		smasv= smasv+sv[soluong[k]].masv()+"\n--------------------------------------------------------------------------\n";
				      		sten = sten+sv[soluong[k]].ten()+"\n--------------------------------------------------------------------------\n";
				      		smail = smail+sv[soluong[k]].mail()+"\n--------------------------------------------------------------------------\n";
				      		slop = slop+sv[soluong[k]].lop()+"\n------------------------------------------------------\n";	
				      		squequan = squequan+sv[soluong[k]].quequan()+"\n--------------------------------------------------------------------------\n";	      		
				      		k++;
				      		}
					      	ht_id.setText(sid);
					      	ht_masv.setText(smasv);
					      	ht_ten.setText(sten);
					      	ht_mail.setText(smail);
					      	ht_lop.setText(slop);
					      	ht_quequan.setText(squequan);
					      	p=trang;
					      	text_page1_s2.setText(p1.valueOf(p));
					      	
	    				}
	    			}
	    		
	    		}
	    	else{
	    		thong_bao.setText(" Trang nay khong ton tai");
	    		}
	    	}
	    //------------------------------------SU LY SU KIEN S3-------------------------------------------
	    if(e.getSource()==update_s3)
	    	{ 
	    		
	    		int in_id_update=Integer.parseInt(text_id_s3.getText());
	    		int in_edit=Integer.parseInt(text_edit_s2.getText());
	      	    if(in_id_update-1<index&&kiem_tra.mail(text_mail_s3.getText())==true){
		      		
		      		String s="";
		      		s=s+"------------------------------------------------------------------------------------------\n";
		      		s=s+"ID\t||   "+text_id_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nMasv\t||   "+text_masv_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nTen\t||   "+text_ten_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nMail\t||   "+text_mail_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nLop\t||   "+text_lop_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nQuequan\t||   "+text_quequan_s3.getText()+"\n------------------------------------------------------------------------------------------";
		      		
		      		ht_s4.setText(s);  		
		      		d_s3.show(false);
	    			d_s4.show(true);
	      		}   
	    	
	    	}
	      
	    if(e.getSource()==back_s3)
	      d_s3.show(false);
	    if(e.getSource()==delete_s3)
	    	{
	    		int in_id_update=Integer.parseInt(text_edit_s2.getText());
	      	    if(in_id_update-1<index&&kiem_tra.mail(text_mail_s3.getText())==true){
		      		
		      		String s="";
		      		s=s+"------------------------------------------------------------------------------------------\n";
		      		s=s+"ID\t||   "+text_edit_s2.getText()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nMasv\t||   "+sv[in_id_update-1].masv()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nTen\t||   "+sv[in_id_update-1].ten()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nMail\t||   "+sv[in_id_update-1].mail()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nLop\t||   "+sv[in_id_update-1].lop()+"\n------------------------------------------------------------------------------------------";
		      		s=s+"\nQuequan\t||   "+sv[in_id_update-1].quequan()+"\n------------------------------------------------------------------------------------------";
		      		
		      		ht_s6.setText(s);  
			    	d_s3.show(false);
			    	d_s6.show(true);   
			    	} 	
	    	}
	      
	    //--------------------------------------------SU LY SU KIEN S4------------------------------------  
	    if(e.getSource()==ok_s4)
	    {
	    	int in_id_update=Integer.parseInt(text_id_s3.getText());
	    	int in_edit=Integer.parseInt(text_edit_s2.getText());
	      	if(in_id_update-1<index&&kiem_tra.mail(text_mail_s3.getText())){
		      		
		      	sv[in_edit-1]=sv[in_id_update-1];
		      	sv[in_id_update-1]=new BanBe(text_masv_s3.getText(),text_ten_s3.getText(),text_mail_s3.getText(),text_lop_s3.getText(),text_quequan_s3.getText());
		      	d_s4.show(false);
	    		d_s5.show(true);
		      	}
		      	
	    	
	    }
	    if(e.getSource()==back_s4)
	    {
	    	d_s4.show(false);
	    	d_s3.show(true);
	    }  
	    //-----------------------------------------------SU LY SU KIEN S5------------------------------------ 
	    if(e.getSource()==ok_s5)
	    {
	    		//neu chuoi tim kiem la rong
	      	if(text_search_s2.getText().length()==0){
	      		    next=0;
			      	sid="";
			      	smasv="";
			      	sten="";
			      	smail="";
			      	slop="";
			      	squequan="";
			      	k=next;
			      	for(int i=0;i<15;i++){
			      		if(k==index)break;
			      		String s=String.valueOf(k+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";
			      		
			      		k++;
			      		}
			      	ht_id.setText(sid);
			      	ht_masv.setText(smasv);
			      	ht_ten.setText(sten);
			      	ht_mail.setText(smail);
			      	ht_lop.setText(slop);
			      	ht_quequan.setText(squequan);
			      	p=1;
			      	a=(float)index/15;
					b=index/15;
					if(a>b)
					   b=b+1;
					text_page2_s2.setText(p2.valueOf(b));
			      	text_page1_s2.setText("1");
			      	
	      		}
	      	//chuoi tim kiem co gia tri
	      	else{      		
	      		sid="";
	      		smasv="";
			    sten="";
			    smail="";
			    slop="";
			    squequan="";
			    next=0;
			    dem_soluong=0;
			    for(int i=0;i<index;i++)
	      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true)
	      			{
	      				soluong[dem_soluong]=i;
	      				dem_soluong++;
	      			}
	      		a=(float)dem_soluong/15;
	      		b=dem_soluong/15;
	      		if(a>b)b=b+1;
			    dem=0;
	      		for(int i=0;i<index;i++){
	      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true){
	      				dem++;
	      				if(dem>15)break;
	      				String s=String.valueOf(i+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[i].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[i].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[i].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[i].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[i].quequan()+"\n--------------------------------------------------------------------------\n";
	      				}
	      				
	      			}
	      		ht_id.setText(sid);
	      		ht_masv.setText(smasv);
			    ht_ten.setText(sten);
			    ht_mail.setText(smail);
			    ht_lop.setText(slop);
			    ht_quequan.setText(squequan);
			    p=1;
			    text_page2_s2.setText(p2.valueOf(b));
	      		text_page1_s2.setText("1"); 
	      		if(dem_soluong==0)
	      		text_page1_s2.setText("0");     			
	      		}
	        text_edit_s2.setText("");
	      	d_s5.show(false);
	    	d_s4.show(false);
	    	d_s3.show(false);	
	      }
	    	
	    

	    //-----------------------------------------------SU LY SU KIEN S6-------------------------------------
	    if(e.getSource()==delete_s6)
	    	{
	    		int xoa=Integer.parseInt(text_edit_s2.getText());
	    		for(int i=xoa-1;i<index;i++)
	    			sv[i]=sv[i+1];    			
	    		index--;   				
		    	d_s6.show(false);
		    	d_s7.show(true);	
	    	}
	      
	    if(e.getSource()==back_s6)
	    {
	    	d_s6.show(false);
	    	d_s3.show(true); 
	    
	    }
	    //------------------------------------------SU LY SU KIEN S7--------------------------------------------
	    if(e.getSource()==ok_s7)
	    {
	    	//neu chuoi tim kiem la rong
	      	if(text_search_s2.getText().length()==0){
	      		    next=0;
			      	sid="";
			      	smasv="";
			      	sten="";
			      	smail="";
			      	slop="";
			      	squequan="";
			      	k=next;
			      	for(int i=0;i<15;i++){
			      		if(k==index)break;
			      		String s=String.valueOf(k+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[k].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[k].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[k].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[k].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[k].quequan()+"\n--------------------------------------------------------------------------\n";
			      		
			      		k++;
			      		}
			      	ht_id.setText(sid);
			      	ht_masv.setText(smasv);
			      	ht_ten.setText(sten);
			      	ht_mail.setText(smail);
			      	ht_lop.setText(slop);
			      	ht_quequan.setText(squequan);
			      	p=1;
			      	a=(float)index/15;
					b=index/15;
					if(a>b)
					   b=b+1;
					text_page2_s2.setText(p2.valueOf(b));
			      	text_page1_s2.setText("1");
			      	
	      		}
	      	//chuoi tim kiem co gia tri
	      	else{      		
	      		sid="";
	      		smasv="";
			    sten="";
			    smail="";
			    slop="";
			    squequan="";
			    next=0;
			    dem_soluong=0;
			    for(int i=0;i<index;i++)
	      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true)
	      			{
	      				soluong[dem_soluong]=i;
	      				dem_soluong++;
	      			}
	      		a=(float)dem_soluong/15;
	      		b=dem_soluong/15;
	      		if(a>b)b=b+1;
			    dem=0;
	      		for(int i=0;i<index;i++){
	      			if(kiem_tra.chuoi(text_search_s2.getText(),sv[i].ten())==true){
	      				dem++;
	      				if(dem>15)break;
	      				String s=String.valueOf(i+1);
			      		sid = sid+s+"\n--------------\n";
			      		smasv = smasv+sv[i].masv()+"\n--------------------------------------------------------------------------\n";
			      		sten = sten+sv[i].ten()+"\n--------------------------------------------------------------------------\n";
			      		smail = smail+sv[i].mail()+"\n--------------------------------------------------------------------------\n";
			      		slop = slop+sv[i].lop()+"\n------------------------------------------------------\n";
			      		squequan = squequan+sv[i].quequan()+"\n--------------------------------------------------------------------------\n";
	      				}
	      				
	      			}
	      		ht_id.setText(sid);
	      		ht_masv.setText(smasv);
			    ht_ten.setText(sten);
			    ht_mail.setText(smail);
			    ht_lop.setText(slop);
			    ht_quequan.setText(squequan);
			    p=1;
			    text_page2_s2.setText(p2.valueOf(b));
	      		text_page1_s2.setText("1"); 
	      		if(dem_soluong==0)
	      		text_page1_s2.setText("0");     			
	      		}
	     
	    	text_edit_s2.setText("");
	    	String sosv=String.valueOf(index);    
	        text_tongsosv_s2.setText(sosv);
	    	d_s7.show(false);
	    	d_s6.show(false);
	    	d_s3.show(false);
	    	d_s4.show(false);
	    }
	    //--------------------------------------------SU LY SU KIEN ThemBan--------------------------------------------
	    if(e.getSource()==register_ThemBan)
	    	{
	        int loi=0;
	        String s="";
	        for(int i=0;i<index;i++){
	    			if(kiem_tra.chuoi(text_ten_ThemBan.getText(),sv[i].ten())==true&&kiem_tra.chuoi(text_mail_ThemBan.getText(),sv[i].mail())==true&&kiem_tra.chuoi(text_lop_ThemBan.getText(),sv[i].lop())==true&&kiem_tra.chuoi(text_masv_ThemBan.getText(),sv[i].masv())==true&&kiem_tra.chuoi(text_quequan_ThemBan.getText(),sv[i].quequan())==true)
	    				loi++;    				
		    			} 
		    if(loi==0){
		    	if(kiem_tra.mail(text_mail_ThemBan.getText())==true&&kiem_tra.masv(text_masv_ThemBan.getText())==true&&kiem_tra.ten(text_ten_ThemBan.getText())==true&&kiem_tra.lop(text_lop_ThemBan.getText())==true&&kiem_tra.quequan(text_quequan_ThemBan.getText())==true){		  		
			    		    s="";
				      		s=s+"\n-------------------------------------------------------------------------------------------\n";
				      		s=s+"Masv\t||   "+text_masv_ThemBan.getText()+"\n-------------------------------------------------------------------------------------------\n";
				      		s=s+"Ten\t||   "+text_ten_ThemBan.getText()+"\n-------------------------------------------------------------------------------------------\n";
				      		s=s+"\nMail\t||   "+text_mail_ThemBan.getText()+"\n-------------------------------------------------------------------------------------------\n";
				      		s=s+"\nlop\t||   "+text_lop_ThemBan.getText()+"\n-------------------------------------------------------------------------------------------\n";
				      		s=s+"Quequan\t||   "+text_quequan_ThemBan.getText()+"\n-------------------------------------------------------------------------------------------\n";
				      		ht_s10.setText(s);    		
			    		d_ThemBan.show(false);
			    		d_s10.show(true);
		    		    
		    		}
		    	else{
		    		thong_bao.setText(" ban chua nhap du thong tin: Format-->>Email:xxx@xxx.xxx ");
	    			d_s.show(true);
		    		}
		    	}
	    	else {
	    		
	    		
	    		thong_bao.setText(" Sinh vien nay da co trong Danh Ba");
	    		d_s.show(true);
	    		}
	    		
	    	}   
	    if(e.getSource()==back_ThemBan)
	      d_ThemBan.show(false);  
	    //----------------------------------------------SU LY SU KIEN S9----------------------------------------
	    if(e.getSource()==ok_s9)
	    {
	    	String sosv=String.valueOf(index);    
	        text_tongsosv_s2.setText(sosv);
	    	d_s9.show(false);
	    	d_ThemBan.show(false);
	    	d_s10.show(false);
	    	this.show(true);  
	    }      
	    //-----------------------------------------------SU LY SU KIEN S10--------------------------------------
	    if(e.getSource()==ok_s10)
	    {
	    		
	    		sv[index]=new BanBe(text_masv_ThemBan.getText(),text_ten_ThemBan.getText(),text_mail_ThemBan.getText(),text_lop_ThemBan.getText(),text_quequan_ThemBan.getText());
	    		index++;  
	    		text_masv_ThemBan.setText(""); 		
	            text_ten_ThemBan.setText("");     
	            text_mail_ThemBan.setText("");     
	            text_lop_ThemBan.setText("");
	            text_quequan_ThemBan.setText(""); 	
	    	d_s10.show(false);
	    	d_s9.show(true);
	    }
	    if(e.getSource()==back_s10)
	    {
	    	d_s10.show(false);
	    	d_ThemBan.show(true);
	    }
	    //--------------------------------------------S---------------------------------------------------------
	    if(e.getSource()==ok_s)
	    {
	    	d_s.show(false);    	
	    }      
	      
	      
	    //---------------------------------------THOAT KHOI CHUONG TRINH-----------------------------------------  
	    if(e.getSource()==logout_s2||e.getSource()==back_s1){

	    	for(int i=0;i<index;i++){
	    		s_masv=s_masv+sv[i].masv()+"\r\n";
	    		s_ten=s_ten+sv[i].ten()+"\r\n";
	    		s_mail=s_mail+sv[i].mail()+"\r\n";
	    		s_lop=s_lop+sv[i].lop()+"\r\n";
	    		s_quequan=s_quequan+sv[i].quequan()+"\r\n";
	    		}
	    	ghi.ghi_index(index);
	    	ghi.ghi_masv(s_masv);
	    	ghi.ghi_ten(s_ten);
	    	ghi.ghi_mail(s_mail);
	    	ghi.ghi_lop(s_lop);
	    	ghi.ghi_quequan(s_quequan);
	    	System.exit(0);
	    	}
	    //------------------------------------------------------------------------------------------------------------  
	  }
	  
	  
	  //HAM MAIN
	  //============================================= 
	  public static void main(String args[])      //|| 
	  { 
	  QLBanBe f=new QLBanBe("S2");//||
	  }

}
